package com.example.kafka.service;

import com.example.kafka.config.KafkaConfig;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;

/**
 * 用例4 工具类
 */
public class ProducerLeakUtil4 {
    public static void send(String msg) {
        // 静态方法中创建 Producer，未关闭
        KafkaProducer<String, String> producer = new KafkaProducer<>(KafkaConfig.getProducerProps());
        producer.send(new ProducerRecord<>("topic4", msg));
        // 未关闭 producer
    }
}